package com.itlong.cloud.controller.workWechat;

import com.itlong.cloud.POJO.DTO.foreign.WorkWechatSendData;
import com.itlong.cloud.annotation.UnAuthAccessRequired;
import com.itlong.cloud.service.WorkWechatPlus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 企业微信告警接口，增强版本，随意切换应用
 * zhouchun
 * 2021-06-03
 */
@RestController
@RequestMapping(path = "/workWechatPlus")
public class WarnPlusController {

    @Autowired
    WorkWechatPlus workWechatPlus;

    @UnAuthAccessRequired
    @RequestMapping("sendText")
    public String sendText(@RequestBody WorkWechatSendData r) {
        String channel = r.getChannel();//根据这个值读取配置实现应用的切换
        String content = r.getContent();
        if (channel == null) {
            return "illegal request";
        }
        return workWechatPlus.sendText(channel, content);
    }

}